#pragma once
#include <iostream>
#include <string>
#include "InetAddr.hpp"
#include<functional>
class Reactor;
class Connection;
using hander_t = std::function<std::string(std::string &)>;
class Connection
{
public:
    Connection()
    :_event(0)
    ,_owner(nullptr)
    {
    }
    virtual void Recver() = 0;
    virtual void Sender() = 0;
    virtual void Excepter() = 0;
    virtual int GetFd() = 0;
    void SetEvent(uint32_t event)
    {
        _event = event;
    }
    uint32_t GetEvent()
    {
        return _event;
    }
    void SetOwner(Reactor *owner)
    {
        _owner = owner;
    }
    Reactor *GetOwner()
    {
        return _owner;
    }
    void RegisterHandler(hander_t handler)
    {
        _handler = handler;
    }
    ~Connection()
    {
    }

private:
    std::string _inbuffer;
    std::string _outbuffer;
    // 回调指针
    Reactor *_owner;
    // 客户端信息
    InetAddr _client;
    // 关心事件
    uint32_t _event;

public:
    hander_t _handler;
};